import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import Admin from 'src/app/model/Admin';
import { MessageService } from '../../core/services/message-service/message.service'

@Component({
  selector: 'Frame-root',
  templateUrl: './Frame.component.html',
  styleUrls: ['./Frame.component.css']
})
export class FrameComponent implements OnInit {

  isCollapsed = false;

  title = "AdminProject"

  admin: Admin = new Admin();

  constructor(private messageService: MessageService, private router:Router) {
    // this.admin = new Admin()
  }

  ngOnInit(): void {
    this.admin = this.messageService.getState('admin')
    if (this.admin === null) {
      this.router.navigate(['/login'])
    }
  }

  exitSystem() {
    this.messageService.setState('admin', null)
    this.router.navigate(['/login'])
  }

}
